<template>
	<view class="content">
       <view class="uni-btn-v">
				<button open-type="getUserInfo" >第一步：获取授权</button>
				<button type="primary" @click="btnReload">第二步:刷新</button>
       	<button type="primary" @click="scan">第三步：请求数据</button>
       </view>
			 <view class="uni-btn-v">
			 	<!-- #ifdef MP-WEIXIN -->
			 	<button type="primary" @tap="weixinPay" >第四步：微信支付</button>
			 	<!-- #endif -->
			 </view>
			 <view class="uni-btn-v">
				 <button type="primary" @click="homelike">打开富文本</button>
			 </view>
			 <view class="uni-btn-v">
			 	<button type="primary" @click="getFromId">获取FormId</button>
			 </view>
	</view>
</template>

<script>
	import api from '@/common/api.js'
	import enums from '@/common/sysEnum.js';
	
	export default {
		data() {
			return {
				title: 'Hello',
				providerList: [],
				res:"",
				formIds:{
					formId: '',
					expire: 0
				},
				submitData:{}
			}
		},
		onLoad() {
      uni.getProvider({
      	service: "payment",
      	success: (e) => {
      		this.providerList = e.provider.map((value) => {
      			switch (value) {
      				case 'alipay':
      					return {
      						name: '支付宝',
      						id: value,
      						loading: false
      					}
      				case 'wxpay':
      					return {
      						name: '微信',
      						id: value,
      						loading: false
      					}
      			}
      		})
				},
				fail: (e) => {
					console.log("获取登录通道失败：", e);
				}
      })
		},
		
		methods: {
			btnReload() {
				let that = this;
				that.loginSystem();
			},
      scan() {
			  let that = this;
			  var sessionkey = that.$store.getters.getSessionKey
				console.log('sessionkey='+sessionkey);
		    api.httpRequest('/wechat/base/getBaseData',{},enums.enums.REQUEST_METHOD.GET,sessionkey).then(res => {
			  	console.log('getBaseData:'+JSON.stringify(res))
			  })
		  },
			// 微信支付
			weixinPay() {
				let that=this;
				console.log("发起支付");
				that.wxPayment();
			},
			
			homelike() {
				uni.redirectTo({
					url: '/pages/demo/homelike'
				})
			},
			getFromId(){
				uni.redirectTo({
					url: '/pages/demo/wxformId'
				})
			}
		}
	}
</script>

<style>
	.content {
		text-align: center;
		height: 400upx;
	}
    .logo{
        height: 200upx;
        width: 200upx;
        margin-top: 200upx;
    }
	.title {
		font-size: 36upx;
		color: #8f8f94;
	}


</style>
